package com.kcdown.train.util;

import java.io.UnsupportedEncodingException;

public class StringUtil
{
	private boolean isChinese(char c)
	{
		Character.UnicodeBlock ub = Character.UnicodeBlock.of(c);
		if (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS
				|| ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS
				|| ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
				|| ub == Character.UnicodeBlock.GENERAL_PUNCTUATION
				|| ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION
				|| ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS)
		{
			return true;
		}
		return false;
	}
	
	public static String big5ToChinese(String s)
	{
		try
		{
			if (s == null || s.equals(""))
				return "";

			String newstring = null;

			newstring = new String(s.getBytes("big5"), "gb2312");

			return newstring;

		}
		catch (UnsupportedEncodingException e)
		{
			return s;
		}

	}

	public static String ChineseTobig5(String s)
	{
		try
		{
			if (s == null || s.equals(""))
				return "";
			String newstring = null;
			newstring = new String(s.getBytes("gb2312"), "big5");
			return newstring;
		}
		catch (UnsupportedEncodingException e)
		{
			return s;
		}

	}
}
